{extend name="layout:base" /}{block name="content"}
 <?php
$global=isSupperManagerForSession();
 ?>
<section class="topBanners">
         <div class="icon"></div>
         <div class="topBannersNav">
         <span data-url="/admin/user/lists" onclick="ContentLoadGo('/admin/user/lists')">用户管理</span>
         </div>
      </section>
   
      <section style="margin-top:10px;margin-left:auto;margin-right:auto;">
      <select name="ser_key" id="ser_key" class="select" >
       <option value="nickname" <?php if($request['ser_key']=="nickname"){echo 'selected';} ?>>姓名</option>
       <option value="phone" <?php if($request['ser_key']=="phone"){echo 'selected';} ?>>手机号</option>
       <option value="uname" <?php if($request['ser_key']=="uname"){echo 'selected';} ?>>登录账号</option>
       <option value="from_source" <?php if($request['ser_key']=="from_source"){echo 'selected';} ?>>来源</option>
      </select>
      <input type="text" class="textbox" name="ser_val" id="ser_val" value="<?php echo $request['ser_val']; ?>" placeholder=""/>
      <select name="firstDep" id="firstDep" class="select firstDeptR">
	       <option value="">--选择--</option>
	       <?php
	       
	       foreach($FirstDepList as $key=>$val)
	   		{
	   		?>
	        <option value="<?php echo $val['id']; ?>" <?php if($val['id']==$request['firstDep']){ echo 'selected';} ?> ><?php echo $val['depname'] ?></option>
		   <?php
	       }
       		?>
          </select>
      <select name="group" id="group" class="select">
       <option value="">--角色--</option>
       <?php
       foreach($groupList as $key=>$val)
	   {
	   ?>
        <option value="<?php echo $val['id']; ?>" <?php if($request['group']==$val['id']){echo 'selected';} ?>><?php echo $val['gname'] ?></option>
	   <?php
       }
       ?>
      </select>
     
      <input type="button" value="搜索" class="group_btn research" id="resource" page="1" />
      	<?php
	    if( ( in_array(21100,$ruleLists) || $global==1) )
		{
    	?>
      <input power="14001" type="button" value="添加" class="group_btn add fr" />
      	<?php
      	}
      	?>
      <br style="clear:both;width:0px;height:0px;">
     </section>


   
<table class="table" style="margin-top:10px;">

<tr>
<th>创建日期</th>
<th>登录账号</th>
<th>手机号</th>
<th>姓名</th>
<th>余额</th>
<th>角色</th>
<th>部门</th>
<th>状态</th>
<th>操作</th>
</tr>

<?php 
foreach($lists['data'] as $key=>$val)
{
?>
<tr data-id="<?php echo $val['id']; ?>">

<td  style="width:160px;"><?php echo $val['ctime'];?></td>
<td  style="width:110px;"><?php echo $val['uname']."<br>[".$val['from_source']."]";?></td>
<td  style="width:110px;"><?php echo $val['phone'];?></td>
<td  style="width:110px;"><?php echo $val['nickname'];?></td>
<td  style="width:110px;"><?php echo $val['money'];?></td>

 <td style="width:110px;">
 <?php
     echo getMyAllGoupNameString(getUserAllGroup($val['id']));
?>
 </td>
 <td style="width:110px;">
 <?php
echo "[".$FirstDepList[$val['first_depid']]['depname']."]";
 ?>
 </td>
<td class="dataStat" style="width:50px;"><?php
 if($val['stat']==0)
{
  echo '正常';
}else if($val['stat']==1)
{
  echo '禁用';
}


 ?></td>

<td style="text-align:right;width:200px;">

    <?php
	    if( ( in_array(21200,$ruleLists) || $global==1) )
		{
    	?>
    <input type="button" power="14002" value="角色配置" class="link_btn userAddGroup"/>
    <?php
		}
		?>
    <?php
	    if( ( in_array(21200,$ruleLists) || $global==1) )
		{
    	?>
    <input type="button" power="14002" value="账户明细" class="link_btn moneyDetail"/>
    <?php
		}
		?>
		<?php
	    if( ( in_array(21200,$ruleLists) || $global==1) )
		{
    	?>
<input type="button" power="14002" value="修改" class="link_btn edit"/>
		<?php
		}
		?>

		<?php
	   if( ( in_array(21300,$ruleLists) || $global==1) )
		{
    	?>
<input type="button" power="14003" value="删除" class="link_btn del"/>
		<?php
		}
		?>
<?php 
if($val['stat']==0)
{
		if( ( in_array(21400,$ruleLists) || $global==1) )
		{
?>
<input type="button" power="14004" value="禁用" class="link_btn jy"/>
<?php
		}
}
else
{
		if( ( in_array(21500,$ruleLists) || $global==1) )
		{
?>
<input type="button" power="14004" value="启用" class="link_btn qy"/>
<?php
		}
}
?>
		<?php
	    if( ( in_array(21600,$ruleLists) || $global==1) )
		{
    	?>
<input type="button" power="14005" value="重置密码" class="link_btn resetPwd"/>
        <?php
        }
		?>
</td>
</tr>
      <?php
      }
	  ?>
</table>
{include file="../application/admin/view/layout/page_tpl_new.html" /}
      <script type="text/javascript">
      
      function myResearch(){
		   var url="/admin/user/lists";
		   var ser_key =$("#ser_key").val();
		   var ser_val =$("#ser_val").val();
		   var firstDep =$("#firstDep").val();
		   var group =$("#group").val();
		   var page=$("#cpage").val();
		   var param={
				   ser_key:ser_key, 
				   ser_val:ser_val, 
				   firstDep:firstDep, 
				   group:group, 
				   page:page
		   };
		   ContentLoadGo(url,param);
	   }
     
      
           $(function(){
        	   //设置搜索栏
        	   $(".research").click(function(){
        		   var page =$(this).attr("page");
        		   $("#cpage").val(page);
        		   myResearch();
        		   
        	   });
        	   

        	   
        	   $(".moneyDetail").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/moneyDetail";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   pid:id
        		   };
        		   ContentLoadGo(url,param);
        	   });

               $(".userAddGroup").unbind().bind("click",function(){
                   var that =this;
                   var url="/admin/user/userAddGroup";
                   var uid=$(that).parent().parent().attr('data-id');
                   var param={
                       uid:uid
                   };
                   ContentLoadGo(url,param);
               });
        	   
        	   

        	   
        	   $(".msg").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/msgList";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   ContentLoadGo(url,param);
        	   });
        	   
        	   $(".del").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/delData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要删除吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   
            				   $(that).parent().parent().remove();
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	   
        	   
        	   
        	   $(".wxopenid").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/wxopenid";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要解绑绑定的微信吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	 
        	 //启用
        	   $(".qy").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/qyData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要启用吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   $(that).val("禁用");
            				  
            				 
            				  $(that).parent().parent().find(".dataStat").html("正常");
            				   $(that).removeClass("qy");
            				   $(that).addClass("jy");
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	 
        	   //禁用
        	    $(".jy").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/jyData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要禁用吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   $(that).val("启用");
            				   
            				   $(that).parent().parent().find(".dataStat").html("禁用");
            				   $(that).removeClass("jy");
            				   $(that).addClass("qy");
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	    $(".edit").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/editData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   MyContentLoad(url,param);
        				 
        				
        			 //弹出：确认按钮
        			
        	   });

        
        	$(".resetPwd").unbind().bind("click",function(){
        		   var that =this;
        		   var url="/admin/user/resetPwd";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   MyContentLoad(url,param);
        				 
        				
        			 //弹出：确认按钮
        			
        	   });
        	   
        	   //导航
         	   $(".topBannerItem").click(function(){
         		   
         		   var attArr = $(this).attr();
             	   goToSelfLink(attArr);
             	   
         			
         	   });
         	  $(".add").unbind().bind("click",function(){
        		   
        		   var that =this;
        		   var url="/admin/user/addData";
        		   var param={};
        		   MyContentLoad(url,param);
        			 //弹出：确认按钮
        			
        	   });
        	   
  			   //全选
  		
  				$("#all").click(function(){   
			    	if(this.checked){   
			        	$(".checkBoxInput").attr("checked", true);  
			        	$(".checkBoxInput").prop("checked", true);  
			    	}else{   
						$(".checkBoxInput").attr("checked", false);
						$(".checkBoxInput").prop("checked", false);
			    	}   
			    	var se=getAllSelectItem();
			    	//console.log(se);
			 	}); 
  			   
  			   
  				 
  			 
           });
           
	  </script>
	  
	  {/block}
   